<?php

namespace App\Repositories;


use App\Interfaces\PictureService;
use App\Models\Picture;
use Config;

class PictureRepository implements PictureService{

    public static function thumb($pic_id,$w='',$h=''){

        $picture = Picture::find($pic_id);

        if ($w!=''&&$h!='') {
            $style='@!'.$w.'-'.$h;
        }else{
            $style='';
        }


        $server_url = @$picture->server_url;
        if($server_url == ''){
            $server_url = Config::get('oss.CdnHost');
        }

        if ($picture){
            return $server_url.'/'.$picture->file_path.$style;

        }else{
            return '';
        }

    }
}